home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLINC.PAK / DOCVIEW.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  23KB  |  750 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1993, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.10  $
  6. //
  7. // Definition of classes TDocument, TView, TWindowView, TStream, TInStream,
  8. // TOutStream
  9. //----------------------------------------------------------------------------
  10. #if !defined(OWL_DOCVIEW_H)
  11. #define OWL_DOCVIEW_H
  12.  
  13. #if !defined(OWL_APPLICAT_H)
  14. # include <owl/applicat.h>
  15. #endif
  16. #if !defined(OWL_FRAMEWIN_H)
  17. # include <owl/framewin.h>
  18. #endif
  19. #if !defined(__COMMDLG_H)
  20. # include <commdlg.h>
  21. #endif
  22.  
  23. #if defined(BI_NAMESPACE)
  24. namespace OWL {
  25. #endif
  26.  
  27. class _OWLCLASS TDocManager;
  28. class _OWLCLASS TDocTemplate;
  29. class _OWLCLASS TMenuDescr;
  30.  
  31. // Generic definitions/compiler options (eg. alignment) preceeding the 
  32. // definition of classes
  33. #include <services/preclass.h>
  34.  
  35. //
  36. // Some types & functions available in Win32/Ole2 that are emulated under Win16
  37. // Note: This must always be in synch with Win32/Ole2 headers
  38. //
  39. #if defined(BI_PLAT_WIN16)
  40. # if !defined(_FILETIME_)
  41.     struct far tagFILETIME {uint32 dwLowDateTime; uint32 dwHighDateTime;};
  42.     typedef tagFILETIME FILETIME;
  43. #   define _FILETIME_
  44. # endif
  45. # include <io.h>
  46.   void DateTimeToFileTime(struct date* dosd, struct time* dost, FILETIME far* pft);
  47.   bool FileTimeToDateTime(FILETIME far* pft, struct date* dosd, struct time* dost);
  48.   int  FormatDateTime(struct date, struct time, void far* dest, int textlen);
  49. #endif
  50. int _OWLFUNC FormatFileTime(FILETIME* pft, void far* dest, int textlen);
  51.  
  52. //
  53. // Document open and sharing modes - used in storage and stream constructors
  54. // Note: the bits values are those of file streams, not same as RTL or OLE
  55. //
  56. enum TDocMode {
  57.   ofParent    = 0,      // use open mode of parent storage
  58.   ofRead      = 0x0001, // ios::in,  open for reading
  59.   ofWrite     = 0x0002, // ios::out, open for writing
  60.   ofReadWrite = (ofRead|ofWrite),
  61.   ofAtEnd     = 0x0004, // ios::ate, seek to eof upon original open
  62.   ofAppend    = 0x0008, // ios::app, append mode: all additions at eof
  63.   ofTruncate  = 0x0010, // ios::trunc, truncate file if already exists
  64.   ofNoCreate  = 0x0020, // ios::nocreate,  open fails if file doesn't exist
  65.   ofNoReplace = 0x0040, // ios::noreplace, open fails if file already exists
  66.   ofBinary    = 0x0080, // ios::binary, binary (not text) file, no CR stripping
  67.   ofIosMask   = 0x00FF, // all of the above bits as used by class ios
  68.  
  69.   ofTransacted= 0x1000, // STGM_TRANSACTED, supports commit and revert
  70.   ofPreserve  = 0x2000, // STGM_CONVERT, backup old data of same name
  71.   ofPriority  = 0x4000, // STGM_PRIORITY, temporary efficient peeking
  72.   ofTemporary = 0x8000, // STGM_DELETEONRELEASE, delete when destructed
  73.  
  74.   shCompat    = 0x0600, // for non-compliant applications, avoid if possible
  75.   shNone      = 0x0800, // EXCLUSIVE functionality
  76.   shRead      = 0x0A00, // DENY_WRITE functionality
  77.   shWrite     = 0x0C00, // DENY_READ functionality
  78.   shReadWrite = 0x0E00, // DENY_NONE functionality
  79.   shDefault   = 0,      // use stream implementation default value
  80.   shMask      = (shCompat|shNone|shRead|shWrite)
  81. };
  82. #define PREV_OPEN           (ofNoCreate|ofNoReplace)
  83. #define IS_PREV_OPEN(omode) ((omode & PREV_OPEN)==PREV_OPEN)
  84.  
  85. //
  86. // Definitions of vnXxxx view notification event IDs
  87. // event ID's up to vnCustomBase reserved for general doc-view notifications
  88. //
  89. const int vnViewOpened  = 1;   // a new view has just been constructed
  90. const int vnViewClosed  = 2;   // another view is about to be destructed
  91. const int vnDocOpened   = 3;   // document has just been opened
  92. const int vnDocClosed   = 4;   // document has just been closed
  93. const int vnCommit      = 5;   // document is committing, flush cached changes
  94. const int vnRevert      = 6;   // document has reverted, reload data from doc
  95. const int vnIsDirty     = 7;   // respond true if uncommitted changes present
  96. const int vnIsWindow    = 8;   // respond true if passed HWND is that of view
  97. const int vnCustomBase = 100;  // base of document class specific notifications
  98.  
  99. //
  100. // Document and view property access flags
  101. //
  102. const int pfGetText   =  1;   // property accessible as text format
  103. const int pfGetBinary =  2;   // property accessible as native non-text format
  104. const int pfConstant  =  4;   // property is invariant for object instance
  105. const int pfSettable  =  8;   // property settable as native format
  106. const int pfUnknown   = 16;   // property defined but unavailable in object
  107. const int pfHidden    = 32;   // property should be hidden from normal browse
  108. const int pfUserDef   =128;   // property has been user-defined at run time
  109.  
  110. //
  111. // Classes defined later in this file
  112. //
  113. class _OWLCLASS_RTL TStream;
  114. class _OWLCLASS_RTL TInStream;
  115. class _OWLCLASS_RTL TOutStream;
  116. class _OWLCLASS TDocument;
  117. class _OWLCLASS TView;
  118.  
  119. //
  120. // class TDocument
  121. // ~~~~~ ~~~~~~~~~
  122. // Abstract base class for document/view management
  123. //
  124. class _OWLCLASS TDocument : public TStreamableBase {
  125.   public:
  126.  
  127.     // Enumeration describing the basic properties of a document.
  128.     // These can be used to update or query the attributes of the 
  129.     // document. See GetProperty and SetProperty for more information.
  130.     //
  131.     enum TDocProp {      
  132.       PrevProperty = 0,  // Index of last property in base class (none in this case)
  133.       DocumentClass,     // text Property: Name of C++ class encapsulating document
  134.       TemplateName,      // text property: Name of template attached to document
  135.       ViewCount,         // int  property: Number of views displaying this document
  136.       StoragePath,       // text property: Identifies object holding data of this document
  137.       DocTitle,          // text property: Caption of this document
  138.       NextProperty,      // Next index to be used by derived class
  139.     };
  140.  
  141.     // Document list class
  142.     //
  143.     class _OWLCLASS TList {
  144.       public:
  145.         TList() : DocList(0) {}
  146.        ~TList() {Destroy();}
  147.         bool Insert(TDocument* doc);  // Insert new document, fails if there
  148.         bool Remove(TDocument* doc);  // Remove document, fails if not there
  149.         TDocument* Next(const TDocument* doc); // Returns first if doc=0
  150.         void Destroy();               // Deletes all documents
  151.  
  152.       private:
  153.         TDocument* DocList;
  154.     };
  155.     typedef TList List;  // for compatibility
  156.  
  157.     // Document constructor / destructor
  158.     //
  159.     TDocument(TDocument* parent = 0);
  160.     virtual ~TDocument();
  161.  
  162.     virtual TInStream*  InStream(int mode, const char far* strmId=0);
  163.     virtual TOutStream* OutStream(int mode, const char far* strmId=0);
  164.  
  165.     virtual bool   Open(int mode, const char far* path=0);
  166.     virtual bool   Close();         // close document, does not delete or detach
  167.     virtual bool   Commit(bool force=false); // save current data, force write
  168.     virtual bool   Revert(bool clear=false); // abort changes, no reload if true
  169.     virtual TDocument& RootDocument();
  170.  
  171.     TDocManager&   GetDocManager();
  172.     void           SetDocManager(TDocManager& dm);
  173.     TDocument*     GetParentDoc();
  174.  
  175.     TDocTemplate*  GetTemplate();
  176.     bool           SetTemplate(TDocTemplate* tpl);
  177.  
  178.     const char far* GetDocPath() const;
  179.     virtual bool    SetDocPath(const char far* path);
  180.  
  181.     const char far* GetTitle() const;
  182.     virtual void   SetTitle(const char far* title);
  183.  
  184.     virtual bool   IsDirty();           // Also queries doc and view hierarchy
  185.     void           SetDirty(bool dirty = true);
  186.  
  187.     virtual bool   IsOpen();
  188.     virtual bool   CanClose();           // Returns false if unable to close
  189.     virtual bool   HasFocus(HWND hwnd);  // Document (or child doc) has Focus
  190.     virtual TDocument* DocWithFocus(HWND hwnd); // Doc/ChildDoc with focus
  191.  
  192.     bool           NotifyViews(int event, long item=0, TView* exclude=0);
  193.     TView*         QueryViews(int event, long item=0, TView* exclude=0);
  194.     virtual uint   PostError(uint sid, uint choice = MB_OK);
  195.  
  196.     // Property access and info
  197.     //
  198.     virtual int    PropertyCount();
  199.     virtual int    FindProperty(const char far* name);// return property index
  200.     virtual int    PropertyFlags(int index);          // pfXxxxx bit array
  201.     virtual const char*  PropertyName(int index);     // locale invariant name
  202.     virtual int    GetProperty(int index, void far* dest, int textlen=0);
  203.     virtual bool   SetProperty(int index, const void far* src); // native type
  204.  
  205.     TView*         GetViewList() const;
  206.     TView*         NextView(const TView* view);
  207.  
  208.     TStream*       GetStreamList() const;
  209.     TStream*       NextStream(const TStream* strm);
  210.  
  211.     void far*      GetTag() const;
  212.     void           SetTag(void* far* tag);
  213.  
  214.     int            GetOpenMode() const;
  215.     void           SetOpenMode(int mode);
  216.  
  217.     TView*         InitView(TView* view);    // called from template InitView
  218.  
  219.     bool           IsEmbedded() const;
  220.     void           SetEmbedded(bool embed);
  221.  
  222.     virtual bool   InitDoc();
  223.  
  224.   protected:
  225.     virtual void  AttachStream(TStream& strm);// called from TStream constructor
  226.     virtual void  DetachStream(TStream& strm);// called from TStream destructor
  227.  
  228.   public_data:
  229.     void far*     Tag;          // application hook, not used internally
  230.     TList         ChildDoc;     // linked child document chain
  231.  
  232.   protected_data:
  233.     bool          DirtyFlag;    // document changed, might not represent views
  234.     bool          Embedded;     // document is an embedding
  235. //  static int    UntitledIndex;// last used index for Untitled document
  236.  
  237.   private:
  238.     TDocManager*  DocManager;   // pointer back to document manager
  239.     TDocument*    NextDoc;      // next in linked chain of active documents
  240.     TView*        ViewList;     // head of linked view chain, 0 if no views
  241.     TStream*      StreamList;   // head of linked stream chain, 0 if no streams
  242.     int           OpenMode;     // mode and protection flags
  243.     char far*     DocPath;      // path used to open/save document
  244.     char far*     Title;        // current document title, 0 if untitled
  245.     TDocument*    ParentDoc;    // parent document, 0 if this is root document
  246.     TDocTemplate* Template;     // template associated with this document
  247.  
  248.     void   ReindexFrames();          // force view title and index update
  249.     void   AttachView(TView& view);  // called from TView constructor
  250.     bool   DetachView(TView& view);  // called from TView destructor
  251.  
  252.     TDocument(TDocManager* docMan);  // create a dummy document to hold docmgr
  253.  
  254.   DECLARE_ABSTRACT_STREAMABLE(_OWLCLASS,TDocument,1);
  255.   friend class _OWLCLASS TDocTemplate;  // access to InitView()
  256.   friend class _OWLCLASS TView;         // access to Attach/DetatchView()
  257.   friend class _OWLCLASS_RTL TStream;   // access to Attach/DetachStream()
  258.   friend class _OWLCLASS TDocManager;
  259.   friend class _OWLCLASS TList;         // access to NextDoc
  260. };
  261.  
  262. //
  263. // class TView
  264. // ~~~~~ ~~~~~
  265. // Abstract base class for view access from document
  266. //
  267. class _OWLCLASS TView : virtual public TEventHandler,
  268.                         virtual public TStreamableBase {
  269.   public:
  270.     enum {
  271.       PrevProperty = 0,
  272.       ViewClass,                  // text
  273.       ViewName,                   // text
  274.       NextProperty,
  275.     };
  276.  
  277.     TView(TDocument& doc);
  278.     virtual ~TView();
  279.  
  280.     TDocument&  GetDocument();
  281.     uint        GetViewId();
  282.  
  283.     virtual TMenuDescr* GetViewMenu();
  284.     void        SetViewMenu(TMenuDescr* menu);
  285.  
  286.     bool        IsOK();           // true if successfully created
  287.  
  288.     static uint GetNextViewId();  // Next global ID to assign
  289.     static void BumpNextViewId();
  290.  
  291.     TView*      GetNextView();
  292.  
  293.     // Must implement, used by template manager for selection
  294.     // static const char far* StaticName() {return "name of view";}
  295.     //
  296.     virtual const char far* GetViewName() = 0;    // return static name of view
  297.  
  298.     virtual TWindow* GetWindow();                 // if not derived from TWindow
  299.     virtual bool   SetDocTitle(const char far* docname, int index);
  300.  
  301.     // Property access and info
  302.     //
  303.     virtual int    PropertyCount();
  304.     virtual int    FindProperty(const char far* name);// return property index
  305.     virtual int    PropertyFlags(int index);          // pfXxxxx bit array
  306.     virtual const char*  PropertyName(int index);     // locale invariant name
  307.     virtual int    GetProperty(int index, void far* dest, int textlen=0);
  308.     virtual bool   SetProperty(int index, const void far* src);
  309.  
  310.     void far*      GetTag() const;
  311.     void           SetTag(void* far* tag);
  312.  
  313.   protected:
  314.     void         NotOK();       // To flag errors in creation
  315.  
  316.   protected_data:
  317.     TDocument*   Doc;
  318.  
  319.   public_data:
  320.     void far*    Tag;           // Application hook, not used internally
  321.  
  322.   private:
  323.     TView*       NextView;      // Linked view chain, 0 if no more views
  324.     uint         ViewId;        // Unique ID for this view, used for controls
  325.     TMenuDescr*  ViewMenu;      // Menu descriptor specific for this view or 0
  326.     static uint  NextViewId;    // Next view ID to be assigned to a view
  327.  
  328.   DECLARE_ABSTRACT_STREAMABLE(_OWLCLASS,TView,1);
  329.   friend class _OWLCLASS TDocument;   // needs access to NextView
  330. #if !defined(BI_NO_OBJ_STREAMING)
  331.   friend class TDocument::Streamer;   // needs access to NextView
  332. #endif
  333. };
  334.  
  335. //
  336. // class TWindowView
  337. // ~~~~~ ~~~~~~~~~~~
  338. class _OWLCLASS TWindowView : public TWindow, public TView {
  339.   public:
  340.     TWindowView(TDocument& doc, TWindow* parent = 0);
  341.    ~TWindowView();
  342.  
  343.     static const char far* StaticName();  // put in resource
  344.  
  345.     // Override virtuals from TWindow
  346.     //
  347.     bool     CanClose();
  348.  
  349.     // Override virtuals from TView
  350.     //
  351.     const char far* GetViewName();
  352.     TWindow* GetWindow();
  353.     bool     SetDocTitle(const char far* docname, int index);
  354.  
  355.   private:
  356.     // Event handlers
  357.     //
  358.     bool     VnIsWindow(HWND hWnd);
  359.  
  360.   DECLARE_RESPONSE_TABLE(TWindowView);
  361.   DECLARE_STREAMABLE (_OWLCLASS, TWindowView,1);
  362. };
  363.  
  364. //
  365. // class TStream
  366. // ~~~~~ ~~~~~~~
  367. // Abstract base class for storage stream access
  368. //
  369. class _OWLCLASS_RTL TStream {
  370.   public:
  371.     TDocument& GetDocument();
  372.    ~TStream();
  373.     int  GetOpenMode();
  374.     const char far* GetStreamName();
  375.  
  376.   protected:
  377.     TDocument& Doc;        // document owning this stream
  378.     TStream* NextStream;   // next stream in linked list of active streams
  379.  
  380.     TStream(TDocument& doc, const char far* name, int mode);
  381.  
  382.   private:
  383.     int             OpenMode;
  384.     const char far* StreamName;
  385.  
  386.   friend class TDocument;
  387. };
  388.  
  389. //
  390. // class TInStream
  391. // ~~~~~ ~~~~~~~~~
  392. // Base Getclass for input streams
  393. //
  394. class _OWLCLASS_RTL TInStream : public TStream, public istream {
  395.   public:
  396.     TInStream(TDocument& doc, const char far* name, int mode);
  397. };
  398.  
  399. //
  400. // class TOutStream
  401. // ~~~~~ ~~~~~~~~~~
  402. // Base class for output streams
  403. //
  404. class _OWLCLASS_RTL TOutStream : public TStream, public ostream {
  405.   public:
  406.     TOutStream(TDocument& doc, const char far* name, int mode);
  407. };
  408.  
  409. // Generic definitions/compiler options (eg. alignment) following the 
  410. // definition of classes
  411. #include <services/posclass.h>
  412.  
  413. //----------------------------------------------------------------------------
  414. // View Notification Handler Definitions
  415. //
  416.  
  417. //
  418. // DocView aliases to actual dispatchers
  419. //
  420. #define B_void_Dispatch     B_Dispatch            // No parameters
  421. #define B_int_Dispatch      B_I2_Dispatch         // LPARAM as int
  422. #define B_pointer_Dispatch  B_POINTER_Dispatch    // LPARAM as void*
  423. #define B_long_Dispatch     B_LPARAM_Dispatch     // LPARAM as long
  424.  
  425. //
  426. // Define a DocView notification signature
  427. //   'id' is the vnXxxXxx name of the notification
  428. //   'arg' is the type of the arg passed to the handler
  429. //
  430. #define NOTIFY_SIG(id, arg) \
  431.   template <class T> \
  432.   inline bool _CALLCNVN (T::*id##_Sig(bool _CALLCNVN (T::*pmf)(arg)))(arg) {return pmf;}
  433.  
  434. NOTIFY_SIG(vnViewOpened,  TView*)
  435. NOTIFY_SIG(vnViewClosed,  TView*)
  436. NOTIFY_SIG(vnDocOpened,   int)
  437. NOTIFY_SIG(vnDocClosed,   int)
  438. NOTIFY_SIG(vnCommit,      bool)
  439. NOTIFY_SIG(vnRevert,      bool)
  440. NOTIFY_SIG(vnIsDirty,     void)
  441. NOTIFY_SIG(vnIsWindow,    HWND)
  442.  
  443. //
  444. // Define a DocView notification response entry
  445. //   'id' is the id from NOTIFY_SIG above
  446. //   'method' is the method name called by the notification
  447. //   'disp' is the type of the lParam dispacher to use, and can be:
  448. //     'void'    lParam not passed
  449. //     'int'     integer size (16bit for win16, or 32bit on win32)
  450. //     'pointer' pointer size (16bit for small & medium, or 32bit all other)
  451. //     'long'    32 bit passed always
  452. //
  453. #define VN_DEFINE(id, method, disp) \
  454.   {WM_OWLNOTIFY, id, \
  455.   (TAnyDispatcher) ::B_##disp##_Dispatch, \
  456.   (TMyPMF)id##_Sig(&TMyClass::method)}
  457.  
  458. #define EV_VN_VIEWOPENED  VN_DEFINE(vnViewOpened,  VnViewOpened,  pointer)
  459. #define EV_VN_VIEWCLOSED  VN_DEFINE(vnViewClosed,  VnViewClosed,  pointer)
  460. #define EV_VN_DOCOPENED   VN_DEFINE(vnDocOpened,   VnDocOpened,   int)
  461. #define EV_VN_DOCCLOSED   VN_DEFINE(vnDocClosed,   VnDocClosed,   int)
  462. #define EV_VN_COMMIT      VN_DEFINE(vnCommit,      VnCommit,      int)
  463. #define EV_VN_REVERT      VN_DEFINE(vnRevert,      VnRevert,      int)
  464. #define EV_VN_ISDIRTY     VN_DEFINE(vnIsDirty,     VnIsDirty,     void)
  465. #define EV_VN_ISWINDOW    VN_DEFINE(vnIsWindow,    VnIsWindow,    int)
  466.  
  467. #if defined(BI_NAMESPACE)
  468. } // namespace OWL
  469. #endif
  470.  
  471. //----------------------------------------------------------------------------
  472. // Inline implementations
  473. //
  474.  
  475. //
  476. inline TInStream* TDocument::InStream(int mode, const char far* strmId) {
  477.   return 0;
  478. }
  479.  
  480. //
  481. inline TOutStream* TDocument::OutStream(int mode, const char far* strmId) {
  482.   return 0;
  483. }
  484.  
  485. //
  486. inline bool TDocument::Open(int mode, const char far* path) {
  487.   return true;
  488. }
  489.  
  490. //
  491. inline TDocManager& TDocument::GetDocManager() {
  492.   return *DocManager;
  493. }
  494.  
  495. //
  496. inline TDocument* TDocument::GetParentDoc() {
  497.   return ParentDoc;
  498. }
  499.  
  500. //
  501. inline TDocTemplate* TDocument::GetTemplate() {
  502.   return Template;
  503. }
  504.  
  505. //
  506. inline const char far* TDocument::GetDocPath() const {
  507.   return DocPath;
  508. }
  509.  
  510. //
  511. inline const char far* TDocument::GetTitle() const {
  512.   return Title;
  513. }
  514.  
  515. //
  516. // Update the document's dirty flag using the specified parameter.
  517. //
  518. inline void TDocument::SetDirty(bool dirty) {
  519.   DirtyFlag = dirty;
  520. }
  521.  
  522. //
  523. inline bool TDocument::IsOpen() {
  524.   return StreamList != 0;
  525. }
  526.  
  527. //
  528. inline int TDocument::PropertyCount() {
  529.   return NextProperty-1;
  530. }
  531.  
  532. //
  533. inline bool TDocument::IsEmbedded() const {
  534.   return Embedded;
  535. }
  536.  
  537. //
  538. inline void TDocument::SetEmbedded(bool embed) {
  539.   Embedded = embed;
  540. }
  541.  
  542. //
  543. inline bool TDocument::InitDoc() {
  544.   return true;
  545. }
  546.  
  547. //
  548. // Return pointer to the head of the link list of views associated with this
  549. // document.
  550. // NOTE: To iterate through all the views, use the 'NextView' method with
  551. //       the pointer obtained from this method.
  552. //
  553. inline TView* TDocument::GetViewList() const {
  554.   return ViewList;
  555. }
  556.  
  557. //
  558. // Return head of the link list of streams associated with this document.
  559. // NOTE: To iterate through all the streams, use the 'NextStream' method 
  560. // with the pointer returned from this method.
  561. //
  562. inline TStream* TDocument::GetStreamList() const {
  563.   return StreamList;
  564. }
  565.  
  566. //
  567. // Return pointer to user-defined data [i.e. tag] attached to this document.
  568. //
  569. inline void far* TDocument::GetTag() const {
  570.   return Tag;
  571. }
  572.  
  573. //
  574. // Attach an arbitrary (user-defined) pointer with this document.
  575. // NOTE: The 'Tag' is a place-holder. It is not used by the Doc/View 
  576. //       subsystem.
  577. //
  578. inline void TDocument::SetTag(void* far* tag) {
  579.   Tag = tag;
  580. }
  581.  
  582. //
  583. inline TDocument::TDocument(TDocManager* docMan)
  584. :
  585.   ParentDoc(this), DocManager(docMan)
  586. {}
  587.  
  588. //
  589. inline int
  590. TDocument::GetOpenMode() const
  591. {
  592.   return OpenMode;
  593. }
  594.  
  595. //
  596. inline void
  597. TDocument::SetOpenMode(int mode)
  598. {
  599.   OpenMode = mode;
  600. }
  601.  
  602. //
  603. inline TDocument& TView::GetDocument() {
  604.   return *Doc;
  605. }
  606.  
  607. //
  608. inline uint TView::GetViewId() {
  609.   return ViewId;
  610. }
  611.  
  612. //
  613. inline TMenuDescr* TView::GetViewMenu() {
  614.   return ViewMenu;
  615. }
  616.  
  617. //
  618. inline bool TView::IsOK() {
  619.   return ViewId != 0;
  620. }
  621. //
  622. inline uint TView::GetNextViewId() {
  623.   return NextViewId;
  624. }
  625.  
  626. //
  627. inline TView* TView::GetNextView() {
  628.   return NextView;
  629. }
  630.  
  631. //
  632. inline TWindow* TView::GetWindow() {
  633.   return 0;
  634. }
  635.  
  636. //
  637. // Retrieve the user-defined pointer attached to this view.
  638. //
  639. inline void far* TView::GetTag() const {
  640.   return Tag;
  641. }
  642.  
  643. //
  644. // Associate an arbitrary (user-defined) pointer with this view.
  645. // NOTE: The 'Tag' is not unsed by the Doc/View subsystem.
  646. //
  647. inline void TView::SetTag(void* far* tag) {
  648.   Tag = tag;
  649. }
  650.  
  651. //
  652. inline bool TView::SetDocTitle(const char far* docname, int index) {
  653.   return false;
  654. }
  655.  
  656. //
  657. inline int TView::PropertyCount() {
  658.   return NextProperty - 1;
  659. }
  660.  
  661. //
  662. inline bool TView::SetProperty(int index, const void far* src) {
  663.   return false;
  664. }
  665.  
  666. //
  667. inline void TView::NotOK() {
  668.   ViewId = 0;
  669. }
  670.  
  671. //
  672. inline TWindowView::~TWindowView() {
  673. }
  674.  
  675. //
  676. inline const char far* TWindowView::StaticName() {
  677.   return "Window View";
  678. }
  679.  
  680. //
  681. // Only query document if this is the last view open to it.
  682. //
  683. inline bool TWindowView::CanClose() {
  684.   return TWindow::CanClose() && 
  685.          (Doc->NextView(this) || 
  686.           Doc->NextView(0) != this ||
  687.           Doc->CanClose());
  688. }
  689.  
  690. //
  691. inline const char far* TWindowView::GetViewName() {
  692.   return StaticName();
  693. }
  694.  
  695. //
  696. inline TWindow* TWindowView::GetWindow() {
  697.   return (TWindow*)this;
  698. }
  699.  
  700. //
  701. inline bool TWindowView::SetDocTitle(const char far* docname, int index) {
  702.   return TWindow::SetDocTitle(docname, index);
  703. }
  704.  
  705. //
  706. inline TDocument& TStream::GetDocument() {
  707.   return Doc;
  708. }
  709.  
  710. //
  711. inline TStream::~TStream() {
  712.   Doc.DetachStream(*this);
  713. }
  714.  
  715. //
  716. inline TStream::TStream(TDocument& doc, const char far* name, int mode)
  717. :
  718.   Doc(doc),
  719.   StreamName(name),
  720.   OpenMode(mode)
  721. {
  722.   Doc.AttachStream(*this);
  723. }
  724.  
  725. //
  726. inline const char far*
  727. TStream::GetStreamName() {
  728.   return StreamName;
  729. }
  730.  
  731. //
  732. inline int
  733. TStream::GetOpenMode() {
  734.   return OpenMode;
  735. }
  736.  
  737. //
  738. inline TInStream::TInStream(TDocument& doc, const char far* name, int mode)
  739. :
  740.   TStream(doc, name, mode), istream()
  741. {}
  742.  
  743. //
  744. inline TOutStream::TOutStream(TDocument& doc, const char far* name, int mode)
  745. :
  746.   TStream(doc, name, mode), ostream()
  747. {}
  748.  
  749. #endif  // OWL_DOCVIEW_H
  750.